﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DataAccessComponents;
using BusinessLogicLayer;

namespace inzDesktop
{
    /// <summary>
    /// Interaction logic for windowListaKlientow.xaml
    /// </summary>
    public partial class windowListaKlientow : Window
    {
        public windowListaKlientow()
        {
            InitializeComponent();
            inicjalizujZawartosc();
        }

        public void inicjalizujZawartosc()
        {
            KlientBL klientBL = new KlientBL();
            dataGridListaKlientow.ItemsSource = klientBL.pobierzListe();
        }

        public Klient Klient { get; set; }
        public Status Status { get; set; }
        private void buttonSzczegoly_Click(object sender, RoutedEventArgs e)
        {
            // Tworzenie obiektu nowego okna                      
            windowSzczegolyKlienta window = new windowSzczegolyKlienta();
            Klient zaznaczonyKlient = (Klient)dataGridListaKlientow.SelectedItem;

            // Przekazywanie idklienta do nowego okna
            window.inicjalizujZawartosc(zaznaczonyKlient.Id_klient);
            window.Show();
        }

        private void btnWybierz_Click(object sender, RoutedEventArgs e)
        {
            if (dataGridListaKlientow.SelectedItem != null)
            {
                windowStatus ws = new windowStatus();
                ws.ShowDialog();

                if (ws.DialogResult.Value == true)
                {
                    this.Status = ws.Status;
                    this.Klient = dataGridListaKlientow.SelectedItem as Klient;
                    DialogResult = true;
                }
                else
                    DialogResult = false;

            }
        }

        private void btnAnuluj_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
